<?php
function ListReview($idP,$type)
{
    global $dbsql,$language,$ParentIdCommen,$TypeComment;
    
    $idP            = intval($idP);
    $ParentIdCommen = $idP;
    $TypeComment    = $type;
    
    $sql_select = "select * from tblreview where iParentId=$idP and cType='$type' and cLanguage='$language' and iStatus=1";
    return $dbsql->load($sql_select);
}

function InsertReview()
{
    global $dbsql,$language;
    require_once "includes/php-captcha.inc.php";
    
    if (PhpCaptcha::Validate($_POST['SpamCode'])==false)
    {
        AjaxTransfer('spam',getLang('Please enter the correct security code!'));
    }
    $ParentId  		= gpc_getIntPost('ParentId');
    $Type           = gpc_getStringPost('Type');
    
    $Name   		= gpc_getStringPost('Name');
   	$Email	     	= gpc_getStringPost('Email');
    $Comment    	= gpc_getStringPost('Comment');
    $Comment        = str_replace("\n","<br>",$Comment);
    
    if($ParentId<=0 || empty($Type))
    {
        AjaxTransfer('false',getLang('Please select Tour!'));
    }
    
    if(empty($Name))
    {
        AjaxTransfer('false',getLang('Please enter your name'));
    }
    if(empty($Email))
    {
        AjaxTransfer('false',getLang('Please enter your email'));
    }
    
    if(empty($Comment))
    {
        AjaxTransfer('false',getLang('Please enter your message'));
    }
    
    $sql_insert     = "insert into tblreview(iParentId,cType,cName,cEmail,cComment,dPostDate,cLanguage)
                        values('$ParentId','$Type','$Name','$Email','$Comment','$postdate','$language')";
    $dbsql->query($sql_insert);
    
    $success        = getConfig('InsertReviewSuccess');
    AjaxTransfer('ok',$success);
}
?>